package com.nl.controller.xuyi.controller;

import com.alibaba.fastjson.JSON;
import com.nl.controller.common.model.BaseResult;
import com.nl.controller.common.model.Response;
import com.nl.controller.web.bean.SmsUsers;
import com.nl.controller.xuyi.bean.linepointcheckbo.LinePointCheckPo;
import com.nl.controller.xuyi.bean.linepointcheckbo.QryLinePointCheckInfoReq;
import com.nl.controller.xuyi.service.XuYiLinePointCheckService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @author zhangheng
 * @date 17:16 2020/9/27
 */
@RestController
@RequestMapping("/xuYiLinePointCheck")
@Slf4j
public class XuYiLinePointCheckController {
	@Autowired
	private XuYiLinePointCheckService xuYiLinePointCheckService;
	/**
	 * desc: 审核信息查询
	 * @param req:
	 * @return: com.nl.controller.common.model.BaseResult<java.lang.Object>
	 * @author zhangheng
	 * @date 2020/9/28 9:53
	 */
	@RequestMapping("/qryLinePointCheckInfo")
	public  Response qryLinePointCheckInfo(@RequestParam(value = "page") int page,
										   @RequestParam(value = "limit") int limit,
										   @RequestParam(value = "checkState") String checkState,
										   @RequestParam(value = "checkType") String checkType
										   ){
		QryLinePointCheckInfoReq req = new QryLinePointCheckInfoReq();
		req.setLimit(limit);
		req.setPage(page);
		req.setCheckState(checkState);
		req.setCheckType(checkType);
		log.info("XuYiLinePointCheckController qryLinePointCheckInfo 审核信息查询 start request: "+ JSON.toJSONString(req));
		Response response = xuYiLinePointCheckService.qryLinePointCheckInfo(req);
		log.info("XuYiLinePointCheckController qryLinePointCheckInfo 审核信息查询 end response: "+ JSON.toJSONString(response));
		return  response;
	}
	/**
	 * desc: 查询审核信息
	 * @param checkId:
	 * @return: com.nl.controller.common.model.BaseResult<java.lang.Object>
	 * @author zhangheng
	 * @date 2020/10/19 15:56
	 */
	@RequestMapping("/qryCheckInfoWithId")
	public BaseResult<Object> qryCheckInfoWithId(@RequestParam(value = "checkId") String checkId){
		log.info("XuYiLinePointCheckController qryLinePointCheckInfo 审核信息查询 start request: "+ JSON.toJSONString(checkId));
		BaseResult<Object> result = xuYiLinePointCheckService.qryCheckInfoWithId(checkId);
		log.info("XuYiLinePointCheckController qryLinePointCheckInfo 审核信息查询 end response: "+ JSON.toJSONString(result));
		return  result;
	}
	/**
	 * desc: 审核点位线路
	 * @param linePointCheckPo:
	 * @param session:
	 * @return: com.nl.controller.common.model.BaseResult<java.lang.Object>
	 * @author zhangheng
	 * @date 2020/10/26 9:42
	 */
	@RequestMapping("/checkLinePoint")
	public BaseResult<Object> checkLinePoint(@RequestBody LinePointCheckPo linePointCheckPo, HttpSession session){
		log.info("XuYiLinePointCheckController qryLinePointCheckInfo 审核点位线路 start request: "+ JSON.toJSONString(linePointCheckPo));
		SmsUsers user = (SmsUsers) session.getAttribute("user");
		linePointCheckPo.setCheckOperator(user.getMsisdn());
		BaseResult<Object> result = xuYiLinePointCheckService.checkLinePoint(linePointCheckPo);
		log.info("XuYiLinePointCheckController qryLinePointCheckInfo 审核点位线路 end response: "+ JSON.toJSONString(result));
		return  result;
	}



}
